#ifndef _UDP_CLIENT_PLUS_H_
#define _UDP_CLIENT_PLUS_H_

#include "event_loop.h"
#include "udp/udp_client.h"
#include "timer_ticker.h"

namespace evnetplus
{

using namespace udp;

class UDPClientPlus {
public:
    using Ptr = std::shared_ptr<UDPClientPlus>;

    explicit UDPClientPlus(EventLoop* loop,
                           const std::string& remote_addr,
                           const std::string& name);
    virtual ~UDPClientPlus();

    void create();

    void destroy();

    void sendMessage(const Slice& message);

    virtual void onReceive(const MessagePtr& msg) {}
    virtual void onTimerHandle() {}

private:
    EventLoop* _loop;
    UDPClientPtr _client;

    struct TimeTickerHelper {
        using Ptr = std::shared_ptr<TimeTickerHelper>;

        Ticker ticker;
        InvokeTimerPtr timer;

        TimeTickerHelper(){}
        ~TimeTickerHelper(){}
    };
    TimeTickerHelper::Ptr _ticker_helper;
    std::mutex _mutex;
};

}

#endif // _UDP_CLIENT_PLUS_H_
